﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
using System.IO;
using System.Data;
using System.Data.SqlClient;

using System.Configuration;
using Ivy.Common.Framework.GeneralUtility;

using Ivy.SiteAdmin.Entity;
using Ivy.SiteAdmin.BusinessLogic;
using Ivy.SiteAdmin.DataAccess;

using Ivy.UserRegistration.Entity;
using Ivy.UserRegistration.DataAccess;
using Ivy.UserRegistration.BusinessLogic;

using Ivy.FeedbackModule.BusinessEntity;
using Ivy.FeedbackModule.Entity;
using Ivy.FeedbackModule.BusinessLogic;
using Ivy.FeedbackModule.IBusinessLogic;

using DasIdeen.ViewEntity;
using System.Text;



namespace DasIdeen.Pages
{
    public partial class TestingPageForSagar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadAllSessionDetails();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {

                ProjectMemberMasterDao_Update();
          
            }
            catch (Exception ex)
            {
                ExceptionUtility.ExceptionHandler(ex,Server.MapPath("~/"));
            }
           
        }

        private void ResourceStatDao_Insert()
        {
            ResourceStat lResourceStat = new ResourceStat();
            ResourceStatDao lResourceStatDao = new ResourceStatDao();

            lResourceStat.ResourceKey = 6;
            lResourceStat.ResourceDescription = "Status Tracker";
            lResourceStat.ResourceTotalDownloads = 10;

            lResourceStat.Sys_CreatedByID = "sagar";

            lResourceStatDao.Insert(lResourceStat);
        }

        private void ResourceStatDao_GetByResourceKey()
        {
            ResourceStat lResourceStat;
            ResourceStatDao lResourceStatDao = new ResourceStatDao();

            lResourceStat = lResourceStatDao.GetByResourceKey(4);
            lResourceStat.ResourceDescription = "Planning Templetes";
            lResourceStat.ResourceTotalDownloads = 10;

            lResourceStat.Sys_CreatedByID = "Sagar";

            lResourceStatDao.Update(lResourceStat);
        }

        private void ResourceStatBus_Insert()
        {
            ResourceStat lResourceStat = new ResourceStat();
            lResourceStat.ResourceKey = 7;
            lResourceStat.ResourceDescription = "MPP File";
            lResourceStat.ResourceTotalDownloads = 5;

            lResourceStat.Sys_CreatedByID = "Sagar";

            
            SiteAdminBus lSiteAdminBus = new SiteAdminBus();
            lSiteAdminBus.AddNewResource(lResourceStat);

        }

        private void ResourceStatBus_Update()
        {
            ResourceStat lResourceStat;
            SiteAdminBus lSiteAdminBus = new SiteAdminBus();
            lResourceStat = lSiteAdminBus.GetSelectedResourceByKey(7);

            lResourceStat.ResourceDescription = "MPP File";
            lResourceStat.ResourceTotalDownloads = 10;

            lResourceStat.Sys_CreatedByID = "Sagar";



            lSiteAdminBus.UpdateResource(lResourceStat);
        }

        private void Sys_LoginHistoryLogDao_Insert()
        {
            Sys_LoginHistoryLog lSys_LoginHistoryLog = new Sys_LoginHistoryLog();
            Sys_LoginHistoryLogDao lSys_LoginHistoryLogDao = new Sys_LoginHistoryLogDao();

            
            lSys_LoginHistoryLog.LoginUserKey = 2;
            lSys_LoginHistoryLog.LoginUserLoginID = "Sagar";
            lSys_LoginHistoryLog.LoginStartTime = Convert.ToDateTime("2014/12/31");
            lSys_LoginHistoryLog.LoginEndTime = Convert.ToDateTime("2014/12/31");
            lSys_LoginHistoryLog.LoginUserBrowser = "GoogleChrome";
            lSys_LoginHistoryLog.LoginLocation = " K.s Layout";

            lSys_LoginHistoryLog.Sys_CreatedByID = "Sagar";

            lSys_LoginHistoryLogDao.Insert(lSys_LoginHistoryLog);

        }

        private void Sys_LoginHistoryLogBus_Insert()
        {
            Sys_LoginHistoryLog lSys_LoginHistoryLog = new Sys_LoginHistoryLog();

            lSys_LoginHistoryLog.LoginKey = 1;
            lSys_LoginHistoryLog.LoginUserKey = 3;
            lSys_LoginHistoryLog.LoginUserLoginID = "Kiran";
            lSys_LoginHistoryLog.LoginStartTime = Convert.ToDateTime("2014/12/31");
            lSys_LoginHistoryLog.LoginEndTime = Convert.ToDateTime("2014/12/31");
            lSys_LoginHistoryLog.LoginUserBrowser = "GoogleChrome";
            lSys_LoginHistoryLog.LoginLocation = " K.s Layout";

            lSys_LoginHistoryLog.Sys_CreatedByID = "Sagar";

            UserRegistrationBus lUserRegistrationBus = new UserRegistrationBus();
            lUserRegistrationBus.RegisterUserLoginHistory(lSys_LoginHistoryLog);


        }

        private void Sys_LoginHistoryLogBus_GetByLoginKey()
        {
            Sys_LoginHistoryLog lSys_LoginHistoryLog;
            UserRegistrationBus lUserRegistrationBus = new UserRegistrationBus();
            lSys_LoginHistoryLog = lUserRegistrationBus.GetUserLoginHistoryByLoginKey(9);

            lSys_LoginHistoryLog.LoginUserKey = 7;
            lSys_LoginHistoryLog.LoginUserLoginID = "Kiran";
            lSys_LoginHistoryLog.LoginStartTime = Convert.ToDateTime("2014/12/31");
            lSys_LoginHistoryLog.LoginEndTime = Convert.ToDateTime("2014/12/31");
            lSys_LoginHistoryLog.LoginUserBrowser = "GoogleChrome";
            lSys_LoginHistoryLog.LoginLocation = " K.s Layout";

            lSys_LoginHistoryLog.Sys_CreatedByID = "Sagar";

           
            lUserRegistrationBus.UpdateRegisteredUserLoginHistory(lSys_LoginHistoryLog);

        }

        private void GetByEmailId_Dao()
        {
            User lUser;
            UserDao lUserDao = new UserDao();
            lUser = lUserDao.GetUserByEmailId("sgrkmr827@gmail.com");

            lUser.UserPassword = "123";
            lUser.UserPassword = StringUtility.EncryptString(lUser.UserPassword);

            lUser.Sys_CreatedByID = "Sagar";

            lUserDao.Update(lUser);

        }

        private void GetByEmailId_Bus()
        {
            UserRegistrationBus lUserRegistrationBus = new UserRegistrationBus();
            User lUser;
            lUser = lUserRegistrationBus.GetUserByPrimaryEmailId("sgrkmr827@gmail.com");
            lUser.UserPassword = "1234";
            lUser.UserPassword = StringUtility.EncryptString(lUser.UserPassword);

            lUserRegistrationBus.UpdateRegisteredUser(lUser);

        }

        private void GetAllUserFeedback()
        {
            List<Feedbacks> lFeedbacks;
            FeedbackModuleBus lFeedbackModuleBus = new FeedbackModuleBus();
            lFeedbacks = lFeedbackModuleBus.GetAllUserFeedback();
           
        }

        private void ContentMetaDataMaster_Insert()
        {
            ContentMetaDataMaster lContentMetaDataMaster = new ContentMetaDataMaster();
            ContentMetaDataMasterDao lContentMetaDataMasterDao = new ContentMetaDataMasterDao();

            lContentMetaDataMaster.ContentName = "Execl sheets";
            lContentMetaDataMaster.ContentHtmlData = "Sample of execl sheets";
            lContentMetaDataMaster.ContentTypeKey = 6;
            lContentMetaDataMaster.ContentTotalDownloads = 12;
            lContentMetaDataMaster.ContentTotalLikes = 9;
            lContentMetaDataMaster.ContentTotalViews = 9;

            lContentMetaDataMaster.Sys_CreatedByID = "sagar";

            lContentMetaDataMasterDao.Insert(lContentMetaDataMaster);
        }

        private void ContentMetaDataMaster_Update()
        {
            ContentMetaDataMaster lContentMetaDataMaster;
            ContentMetaDataMasterDao lContentMetaDataMasterDao = new ContentMetaDataMasterDao();

            lContentMetaDataMaster = lContentMetaDataMasterDao.GetByContentKey(4);

            lContentMetaDataMaster.ContentName = "Templetess";
            lContentMetaDataMaster.ContentHtmlData = "Templete's";
            lContentMetaDataMaster.ContentTypeKey = 7;
            lContentMetaDataMaster.ContentTotalDownloads = 30;
            lContentMetaDataMaster.ContentTotalLikes = 89;
            lContentMetaDataMaster.ContentTotalViews = 99;

            //lContentMetaDataMaster.Sys_CreatedByID = "sagar";

            lContentMetaDataMasterDao.Update(lContentMetaDataMaster);

        }

        private void ContnetMeatDataMaster_GetByContentCode()
        {
            ContentMetaDataMaster lContentMetaDataMaster;
            SiteAdminContentManagementBus lSiteAdminContentManagementBus = new SiteAdminContentManagementBus();
            lContentMetaDataMaster = lSiteAdminContentManagementBus.GetSelectedContentMetaDataByContentCode("DFLT_BLG");

        }

        private void ContentFeedbackDao_Insert()
        {
            ContentFeedback lContentFeedback = new ContentFeedback();
            ContentFeedbackDao lContentFeedbackDao = new ContentFeedbackDao();

            lContentFeedback.ContentFeedbackContentKey = 8;
            lContentFeedback.ContentFeedbackFeedbackKey = 0;
            lContentFeedback.ContentFeedbackText = "Very good excel sheets and formatted very well. It's very help full for me.";
            lContentFeedback.ContentFeedbackDate = Convert.ToDateTime("2015/02/28");
            lContentFeedback.ContentFeedbackAuthorUserKey = 4;
            lContentFeedback.ContentFeedbackAuthorName = "Kailash";
            lContentFeedback.ContentFeedbackAuthorEmail = "kailash@gmail.com";

            lContentFeedback.Sys_CreatedByID = "sagar";
            lContentFeedbackDao.Insert(lContentFeedback);
        }

        private void ContentFeedbackDao_Update()
        {
            ContentFeedback lContentFeedback;
            ContentFeedbackDao lContentFeedbackDao = new ContentFeedbackDao();

            lContentFeedback = lContentFeedbackDao.GetByContentFeedbackKey(1);

            //lContentFeedback.ContentFeedbackContentKey = 3;
            //lContentFeedback.ContentFeedbackFeedbackKey = 3;
            lContentFeedback.ContentFeedbackText = "Hello everyone";
            lContentFeedback.ContentFeedbackDate = Convert.ToDateTime("2015/01/21");
            lContentFeedback.ContentFeedbackAuthorUserKey = 1;
            lContentFeedback.ContentFeedbackAuthorName = "Kailash";
            lContentFeedback.ContentFeedbackAuthorEmail = "sgr@gmail.com";

            lContentFeedback.Sys_CreatedByID = "sagar";
            lContentFeedbackDao.Update(lContentFeedback);
        }

        private List<ContentFeedback> GetByContentFeedbackContentKey_List(int ContentFeedbackContentKey)
        {
            List<ContentFeedback> lContentFeedback;
            ContentFeedbackDao lContentFeedbackDao = new ContentFeedbackDao();
            lContentFeedback = lContentFeedbackDao.GetByContentFeedbackContentKey(ContentFeedbackContentKey);

           return lContentFeedback;
        }

        private List<ContentFeedback> GetByContentFeedbackFeedbackKey_List(int ContentFeedbackFeedbackKey)
        {
            List<ContentFeedback> lContentFeedback;
            ContentFeedbackDao lContentFeedbackDao = new ContentFeedbackDao();
            lContentFeedback = lContentFeedbackDao.GetByContentFeedbackFeedbackKey(ContentFeedbackFeedbackKey);

            return lContentFeedback;
        }

        private void ContactRequestRegisterDao_Insert()
        {
            ContactRequestRegister lContactRequestRegister = new ContactRequestRegister();
            ContactRequestRegisterDao lContactRequestRegisterDao = new ContactRequestRegisterDao();

            lContactRequestRegister.ContactRequesterName = "Sagar";
            lContactRequestRegister.ContactRequesterEmail = "g@gmail.com";
            lContactRequestRegister.ContactRequestMessage = "Hi Everyone";

            lContactRequestRegister.Sys_CreatedByID = "sagar";

            lContactRequestRegisterDao.Insert(lContactRequestRegister);
        }


        private void ContactRequestRegisterDao_Update()
        {
            ContactRequestRegister lContactRequestRegister;
            ContactRequestRegisterDao lContactRequestRegisterDao = new ContactRequestRegisterDao();
            lContactRequestRegister = lContactRequestRegisterDao.GetByContactRequestKey(1);

            lContactRequestRegister.ContactRequesterName = "Kailash";
            lContactRequestRegister.ContactRequesterEmail = "g@gmail.com";
            lContactRequestRegister.ContactRequestMessage = "Hi Everyone";

            lContactRequestRegisterDao.Update(lContactRequestRegister);
        }

        private List<ContentFeedbacks> GetContentFeedbackByContentCode(string ContentCode)
        {
            List<ContentFeedbacks> lContentFeedbacks;
            SiteAdminContentManagementBus lSiteAdminContentManagementBus = new SiteAdminContentManagementBus();
            lContentFeedbacks = lSiteAdminContentManagementBus.GetSelectedContentFeedbackByContentCode(ContentCode);

            return lContentFeedbacks;
        }

        private void demo()
        {
            //string FileNamePath = @"C:\HSMPortal Related\ProjectSource\VS2010\DasIdeenWebsite\DasIdeen\UploadDownloadContents\Dasideen_Logs_Text\Demo.txt";
            //FileUtility lFileUtility = new FileUtility();

            //lFileUtility.Logs(FileNamePath);
            Exception lException = new Exception("TestExpection");
            throw lException;
        }

        private void ContentRating_Dao_Insert()
        {
            ContentRating lContentRating = new ContentRating();
            ContentRatingDao lContentRatingDao = new ContentRatingDao();

            lContentRating.ContentRatingContentKey = 8;
            lContentRating.ContentRatingValue = 2;
            lContentRating.ContentRatingDate = Convert.ToDateTime("2015/04/18");
            lContentRating.ContentRatingProviderUserKey = 3;
            lContentRating.ContentRatingProviderName = "sagar";
            lContentRating.ContentRatingProviderEmail = "sgrkmr827@gmail.com";

            lContentRating.Sys_CreatedByID = "sagar";

            lContentRatingDao.Insert(lContentRating);
        }

        private void ContnetRating_Daa_Update()
        {
            List<ContentRating> lContentRating = new List<ContentRating>();
            
            ContentRatingDao lContentRatingDao = new ContentRatingDao();
            lContentRating = lContentRatingDao.GetByContentKey(9);

        }

        private void GetAllContentStatistics()
        {
            List<ContentStatistics> lContentStatistics;
            //ContentMetaDataMasterDao lContentMetaDataMasterDao = new ContentMetaDataMasterDao();
            SiteAdminContentManagementBus lSiteAdminContentManagementBus = new SiteAdminContentManagementBus();
            lContentStatistics = lSiteAdminContentManagementBus.GetAllContentMetaDataWithContentStatistics(1);
        }

        private void GetSeletedContentStatistics()
        {
            ContentStatistics lContentStatistics;
            SiteAdminContentManagementBus lSiteAdminContentManagementBus = new SiteAdminContentManagementBus();
            lContentStatistics = lSiteAdminContentManagementBus.GetSelectedContentMetaDataWithContentStatisticsByContentkey(12);
        }

        private void ContentLikes(int ContentKey)
        {
            ContentMetaDataMaster lContentMetaDataMaster = new ContentMetaDataMaster();
            SiteAdminContentManagementBus lSiteAdminContentManagementBus = new SiteAdminContentManagementBus();

            lSiteAdminContentManagementBus.SaveContentLikes(ContentKey);
            lContentMetaDataMaster.ContentTotalLikes = 10;

            lSiteAdminContentManagementBus.UpdateContentMetaData(lContentMetaDataMaster);


        }

        private void Sys_ErrorLog_Insert()
        {
            Sys_ErrorLog lSys_ErrorLog = new Sys_ErrorLog();
            Sys_ErrorLogDao lSys_ErrorLogDao = new Sys_ErrorLogDao();

            lSys_ErrorLog.ApplicationName = "Dasideen";
            lSys_ErrorLog.MethodName = "Insert";
            lSys_ErrorLog.ErrorMessage = "For Inserting new Sys_ErrorLog entity data to database,[EntityState] attribute should be [New]";
            lSys_ErrorLog.StackTrace = null;
            lSys_ErrorLog.Sys_CreatedByID = "sagar";
            lSys_ErrorLogDao.Insert(lSys_ErrorLog);
        }

        private void Sys_ErrorLog_Update(int ErrorLogPrimaryID)
        {
            Sys_ErrorLog lSys_ErrorLog = new Sys_ErrorLog();
            Sys_ErrorLogDao lSys_ErrorLogDao = new Sys_ErrorLogDao();

            lSys_ErrorLog.ApplicationName = "DasIdeen";
            lSys_ErrorLog.MethodName = "Update";
            lSys_ErrorLog.ErrorMessage = "Sys_ErrorLog entity data to database,[EntityState] attribute should be [New]";
            lSys_ErrorLog.Sys_CreatedByID = "sagar";
            lSys_ErrorLogDao.Update(lSys_ErrorLog);
        }

        private void GetUserProfileImageByKey(int UserKey)
        {
            UserProfileImage lUserProfileImage;
            UserProfileImageDao lUserProfileImageDao = new UserProfileImageDao();

            lUserProfileImage = lUserProfileImageDao.GetByUserKey(UserKey);
            this.Image1.ImageUrl = "data:" + lUserProfileImage.UserImageType + ";base64," + Convert.ToBase64String(lUserProfileImage.UserImageData);
             
        }

        private void UserProfileImage_Insert(byte[] pImageData, string pFilePath, string pImageType)
        {
            UserProfileImage lUserProfileImage = new UserProfileImage();
            UserProfileImageDao lUserProfileImageDao = new UserProfileImageDao();

            lUserProfileImage.UserKey = 1;
            lUserProfileImage.UserLoginID = "SystemSuperAdmin";
            lUserProfileImage.UserImageData = pImageData;
            lUserProfileImage.UserImageType = pImageType;
            lUserProfileImage.UserImageFileName = pFilePath;
            lUserProfileImage.Sys_CreatedByID = "-1";

            lUserProfileImageDao.Insert(lUserProfileImage);
        }

        protected void btnUploadImage_Click(object sender, System.EventArgs e)
        {
            string ImageName = string.Empty;
            byte[] ImageData = null;
            if (FileUpload.PostedFile != null && FileUpload.PostedFile.FileName != "")
            {
                ImageName = Path.GetFileName(FileUpload.FileName);
                ImageData = new byte[FileUpload.PostedFile.ContentLength];
                HttpPostedFile UploadedImage = FileUpload.PostedFile;
                UploadedImage.InputStream.Read(ImageData, 0, (int)FileUpload.PostedFile.ContentLength);

                //ContentBinaryDataContenDaot_Insert(ImageData, FileUpload.PostedFile.FileName, FileUpload.PostedFile.ContentType);

                ContentBinaryDataContenDao_Update(ImageData, FileUpload.PostedFile.FileName, FileUpload.PostedFile.ContentType);

                this.Image1.ImageUrl = "data:" + FileUpload.PostedFile.ContentType + ";base64," + Convert.ToBase64String(ImageData);
            }
        }

        private void Sys_SessionLogDao_Insert()
        {
            Sys_SessionLog lSys_SessionLog = new Sys_SessionLog();
            //Sys_SessionLogDao lSys_SessionLogDao = new Sys_SessionLogDao();

            UserRegistrationBus lUserRegistrationBus = new UserRegistrationBus();
            
            lSys_SessionLog.SessionLogPrimaryID = 5;
            lSys_SessionLog.UserSessionID = "46545";
            lSys_SessionLog.UserIPAddress = "198.56.23.10";
            lSys_SessionLog.UserSessionEndTime = Convert.ToDateTime("2015/04/18");
            lSys_SessionLog.UserSessionEndTime = Convert.ToDateTime("2015/04/18");
            lSys_SessionLog.UserKey = 1;

            lSys_SessionLog.Sys_CreatedByID = "-1";

            lUserRegistrationBus.SaveUserSys_SessionLogDetails(lSys_SessionLog);
        }

        private void Sys_SessioErrorDao_Insert()
        {
            Sys_ErrorLog lSys_ErrorLog = new Sys_ErrorLog();
            //Sys_ErrorLogDao lSys_ErrorLogDao = new Sys_ErrorLogDao();
            SiteAdminContentManagementBus lSiteAdminContentManagementBus = new SiteAdminContentManagementBus();

            lSys_ErrorLog.ApplicationName = "Codeplex";
            lSys_ErrorLog.MethodName = "Delete";
            lSys_ErrorLog.ErrorMessage = "In Update Mehtod";

            lSys_ErrorLog.Sys_CreatedByID = "-1";

            lSiteAdminContentManagementBus.SaveSys_ErrorLogDetails(lSys_ErrorLog);


            
        }

        private void ContentBinaryDataContenDaot_Insert(byte[] pData, string pFilePath, string pContentType)
        {
            ContentBinaryDataContent lContentBinaryDataContent = new ContentBinaryDataContent();
            ContentBinaryDataContentDao lContentBinaryDataContentDao = new ContentBinaryDataContentDao();

            lContentBinaryDataContent.ContentMetaDataKey = 2;
            lContentBinaryDataContent.ContentBinaryData = pData;
            lContentBinaryDataContent.ContentThumbnailImage = pData;
            lContentBinaryDataContent.ContentBinaryDataFileName = pFilePath;
            lContentBinaryDataContent.ContentBinaryDataType = pContentType;
            lContentBinaryDataContent.ContentTotalDownloads = 10;

            lContentBinaryDataContent.Sys_CreatedByID = "-1";

            lContentBinaryDataContentDao.Insert(lContentBinaryDataContent);

        }

        private void ContentBinaryDataContenDao_Update(byte[] pData, string pFilePath, string pContentType)
        {
            ContentBinaryDataContent lContentBinaryDataContent = new ContentBinaryDataContent();
            ContentBinaryDataContentDao lContentBinaryDataContentDao = new ContentBinaryDataContentDao();

            lContentBinaryDataContent = lContentBinaryDataContentDao.GetByContentMetaDataKey(1);

            lContentBinaryDataContent.ContentBinaryData = pData;
            lContentBinaryDataContent.ContentThumbnailImage = pData;
            lContentBinaryDataContent.ContentBinaryDataFileName = pFilePath;
            lContentBinaryDataContent.ContentBinaryDataType = pContentType;
            lContentBinaryDataContent.ContentTotalDownloads = 10;

            lContentBinaryDataContent.Sys_CreatedByID = "-1";

            lContentBinaryDataContentDao.Update(lContentBinaryDataContent);
        }

        private void ProjectMemberMasterDao_Insert()
        {
            ProjectMemberMaster lProjectMemberMaster = new ProjectMemberMaster();
            ProjectMemberMasterDao lProjectMemberMasterDao = new ProjectMemberMasterDao();

            lProjectMemberMaster.ProjectMemberKey = 1;
            lProjectMemberMaster.ProjectMemberUserKey = 2;
            lProjectMemberMaster.ProjectMemberFirstName = "sagar";
            lProjectMemberMaster.ProjectMemberLastName = "k";
            lProjectMemberMaster.ProjectMemberPrimaryEmailID = "sgrkmr827@gmail.com";
            lProjectMemberMaster.ProjectMemberCodePlexID = "sagar";
            lProjectMemberMaster.ProjectMemberSkypeID = "sagar@hotmail.com";
            lProjectMemberMaster.ProjectMemberMicrosoftID = "sagar249@hotmail.com";
            lProjectMemberMaster.ProjectMemberGoogleID = "sg@gmail.com";
            lProjectMemberMaster.ProjectMemberTimeZoneReference = "Banaglore";
            lProjectMemberMaster.ProjectMemberTimeZoneName = "Bangalore";
            lProjectMemberMaster.ProjectMemberTimeZoneAbbreviation = "something";
            lProjectMemberMaster.ProjectMemberCountryName = "India";
            lProjectMemberMaster.ProjectMemberCityName = "Bangalore";
            lProjectMemberMaster.ProjectMemberDateOfJoining = Convert.ToDateTime("2014/12/31");
            lProjectMemberMaster.ProjectMemberIsMemberOfFacebook = true;

            lProjectMemberMaster.Sys_CreatedByID = "sagar";
            lProjectMemberMasterDao.Insert(lProjectMemberMaster);
        }
        private void ProjectMemberMasterDao_Update()
        {
            ProjectMemberMaster lProjectMemberMaster = new ProjectMemberMaster();
            ProjectMemberMasterDao lProjectMemberMasterDao = new ProjectMemberMasterDao();
            lProjectMemberMaster = lProjectMemberMasterDao.GetByProjectMemberKey(1);

            lProjectMemberMaster.ProjectMemberUserKey = 2;
            lProjectMemberMaster.ProjectMemberFirstName = "Pravesh";
            lProjectMemberMaster.ProjectMemberLastName = "k";
            lProjectMemberMaster.ProjectMemberPrimaryEmailID = "Pravesh@gmail.com";
            lProjectMemberMaster.ProjectMemberCodePlexID = "sagar";
            lProjectMemberMaster.ProjectMemberSkypeID = "Pravesh@hotmail.com";
            lProjectMemberMaster.ProjectMemberMicrosoftID = "Pravesh@hotmail.com";
            lProjectMemberMaster.ProjectMemberGoogleID = "Pravesh@gmail.com";
            lProjectMemberMaster.ProjectMemberTimeZoneReference = "Banaglore";
            lProjectMemberMaster.ProjectMemberTimeZoneName = "Bangalore";
            lProjectMemberMaster.ProjectMemberTimeZoneAbbreviation = "something";
            lProjectMemberMaster.ProjectMemberCountryName = "India";
            lProjectMemberMaster.ProjectMemberCityName = "Bangalore";
            lProjectMemberMaster.ProjectMemberDateOfJoining = Convert.ToDateTime("2014/12/31");
            lProjectMemberMaster.ProjectMemberIsMemberOfFacebook = true;

            lProjectMemberMaster.Sys_CreatedByID = "sagar";
            lProjectMemberMasterDao.Update(lProjectMemberMaster);
        }

        protected void btnDownloadDataAsExcel_Click(object sender, EventArgs e)
        {
            List<Sys_SessionLog> lSys_SessionLogList = new List<Sys_SessionLog>();
            UserRegistrationBus lUserRegistrationBus = new UserRegistrationBus();
            lSys_SessionLogList = lUserRegistrationBus.GetAllSys_SessionLogDetails();

            if (lSys_SessionLogList.Count > 0)
            {
                string header = @"""SessionLogPrimaryID"",""UserSessionID"",""UserIPAddress"",""UserSessionStartTime"",""UserSessionEndTime"",""UserBrowserName""";

                StringBuilder sb = new StringBuilder();
                sb.AppendLine(header);
                foreach (Sys_SessionLog lSys_SessionLog in lSys_SessionLogList)
                {
                    sb.AppendLine(string.Join(",",
                        string.Format(@"""{0}""", lSys_SessionLog.SessionLogPrimaryID),
                        string.Format(@"""{0}""", lSys_SessionLog.UserSessionID),
                        string.Format(@"""{0}""", lSys_SessionLog.UserIPAddress),
                        string.Format(@"""{0}""", lSys_SessionLog.UserSessionStartTime),
                        string.Format(@"""{0}""", lSys_SessionLog.UserSessionEndTime),
                        string.Format(@"""{0}""", lSys_SessionLog.UserBrowserName)));
                }
                HttpContext context = HttpContext.Current;
                context.Response.Write(sb.ToString());
                context.Response.ContentType = "text/csv";
                context.Response.AddHeader("Content-Disposition", "attachment; filename=Sys_SessionLogDetails.csv");
                context.Response.End();
            }
            
            //Response.ClearContent();
            //Response.Buffer = true;
            //Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Sys_SessionLogDetails.xls"));
            //Response.ContentType = "application/ms-excel";
            //DataTable dt = GetDatafromDatabase();
            //string str = string.Empty;
            //foreach (DataColumn dtcol in dt.Columns)
            //{
            //    Response.Write(str + dtcol.ColumnName);
            //    str = "\t";
            //}
            //Response.Write("\n");
            //foreach (DataRow dr in dt.Rows)
            //{
            //    str = "";
            //    for (int j = 0; j < dt.Columns.Count; j++)
            //    {
            //        Response.Write(str + Convert.ToString(dr[j]));
            //        str = "\t";
            //    }
            //    Response.Write("\n");
            //}
            //Response.End();
        }

        protected DataTable GetDatafromDatabase()
        {
            DataTable dt = new DataTable();
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SAGAR_SqlDBConnection"].ToString()))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("Select UserSessionID,UserIPAddress,UserSessionStartTime,UserSessionEndTime,UserBrowserName from Sys_SessionLog", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                con.Close();
            }
            return dt;
        }

        public override void VerifyRenderingInServerForm(Control control)
        {
            /* Verifies that the control is rendered */
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            //Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
            Response.ContentType = "application/ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gvDetails.AllowPaging = false;
            gvDetails.DataSource = LoadAllSessionDetails();
            gvDetails.DataBind();
            //Change the Header Row back to white color
            gvDetails.HeaderRow.Style.Add("background-color", "#FFFFFF");
            //Applying stlye to gridview header cells
            for (int i = 0; i < gvDetails.HeaderRow.Cells.Count; i++)
            {
                gvDetails.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
            }
            gvDetails.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();
        }

        private List<Sys_SessionLog> LoadAllSessionDetails()
        {
            List<Sys_SessionLog> lSys_SessionLog = new List<Sys_SessionLog>();
            UserRegistrationBus lUserRegistrationBus = new UserRegistrationBus();
            lSys_SessionLog = lUserRegistrationBus.GetAllSys_SessionLogDetails();
            this.gvDetails.DataSource = lSys_SessionLog;
            this.gvDetails.DataBind();
            return lSys_SessionLog;
        }
    }
}